In [1]:
require 'daru/view'
Out[1]:
In [2]:
Daru::View.plotting_library = :googlecharts
Out[2]:
In [4]:
data = [
['Year', 'Sales', 'Expenses'],
['2013', 1000, 400],
['2014', 1170, 460],
['2015', 660, 1120],
['2016', 1030, 540]
]
area_chart_table = Daru::View::Table.new(data)
area_chart_table.show_in_iruby
Out[4]:
In [9]:
area_chart_options = {
type: :area
}
area_chart_chart = Daru::View::Plot.new(area_chart_table.table, area_chart_options)
area_chart_chart.show_in_iruby
Out[9]:
In [12]:
area_chart_options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: '#333'}},
vAxis: {minValue: 0},
type: :area
}
area_chart_chart = Daru::View::Plot.new(area_chart_table.table, area_chart_options)
area_chart_chart.show_in_iruby
Out[12]:
In [17]:
area_chart_options = {
isStacked: true,
height: 300,
legend: {position: 'top', maxLines: 3},
vAxis: {minValue: 0},
type: :area
}
area_chart_chart = Daru::View::Plot.new(area_chart_table.table, area_chart_options)
area_chart_chart.show_in_iruby
Out[17]:
In [15]:
area_chart_options = {
isStacked: 'relative',
height: 300,
legend: {position: 'top', maxLines: 3},
vAxis: {
minValue: 0,
ticks: [0, 0.3, 0.6, 0.9, 1]
},
type: :area
}
area_chart_chart = Daru::View::Plot.new(area_chart_table.table, area_chart_options)
area_chart_chart.show_in_iruby
Out[15]:
In [ ]: